package com.eastfair.venuebooking.controller;

import cn.hutool.core.date.DateUnit;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eastfair.boot.request.PageParams;
import com.eastfair.core.base.R;
import com.eastfair.util.DateTimeUtil;
import com.eastfair.venuebooking.dto.BusinessOpportunityQuery;
import com.eastfair.venuebooking.dto.SalesAnalysisDTO;
import com.eastfair.venuebooking.service.StatisticalAnalysisService;
import com.eastfair.venuebooking.vo.BusinessOpportunityVO;
import com.eastfair.venuebooking.vo.SpaceLeaseStatisticsTotalVO;
import com.eastfair.venuebooking.vo.SpaceVO;
import com.eastfair.venuebooking.vo.StatisticalAnalysisTotalVO;
import io.swagger.annotations.ApiOperation;
import io.undertow.util.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * 统计分析
 * </p>
 *
 * @author lyw
 * @date 2022-07-04
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/statistical")
public class StatisticalAnalysisController {

    @Autowired
    private StatisticalAnalysisService statisticalAnalysisService;


    /**
     * 销售分析数据
     *
     * @return
     */
    @ApiOperation(value = "销售分析数据")
    @PostMapping(value = "/getStatisticalAnalysisTotalData")
   public R<StatisticalAnalysisTotalVO> getStatisticalAnalysisTotalData(@RequestBody SalesAnalysisDTO salesAnalysisDTO){
        StatisticalAnalysisTotalVO statisticalAnalysisTotalVO= statisticalAnalysisService.getStatisticalAnalysisTotalData(salesAnalysisDTO);
       return R.successDef(statisticalAnalysisTotalVO);
   }

    /**
     * 获取某个销售阶段数据集合
     *
     * @return
     */
    @ApiOperation(value = "获取某个销售阶段数据集合")
    @PostMapping(value = "/getStatisticalAnalysis")
    public R<IPage<BusinessOpportunityVO>> getStatisticalAnalysis(@RequestBody PageParams<SalesAnalysisDTO> pageParams){
        IPage<BusinessOpportunityVO> pageList= statisticalAnalysisService.getStatisticalAnalysisByCode(pageParams);
        return R.successDef(pageList);
    }




    /**
     * 场地出租率统计数据
     *
     * @return
     */
    @ApiOperation(value = "场地出租率统计数据")
    @PostMapping(value = "/getSpaceLeaseStatisticsTotalData")
    public R<SpaceLeaseStatisticsTotalVO> getSpaceLeaseStatisticsTotalData(@RequestBody SalesAnalysisDTO salesAnalysisDTO){
        SpaceLeaseStatisticsTotalVO spaceLeaseStatisticsTotalVO= statisticalAnalysisService.getSpaceLeaseStatisticsTotalData(salesAnalysisDTO);
        return R.successDef(spaceLeaseStatisticsTotalVO);
    }


    /**
     * 场地出租面积统计数据
     *
     * @return
     */
    @ApiOperation(value = "场地出租面积统计数据")
    @PostMapping(value = "/getSpaceLeaseStatisticsTotalArea")
    public R<SpaceLeaseStatisticsTotalVO> getSpaceLeaseStatisticsTotalArea(@RequestBody SalesAnalysisDTO salesAnalysisDTO){
        SpaceLeaseStatisticsTotalVO spaceLeaseStatisticsTotalVO= statisticalAnalysisService.getSpaceLeaseStatisticsTotalArea(salesAnalysisDTO);
        return R.successDef(spaceLeaseStatisticsTotalVO);
    }






}
